import java.util.Arrays;

public class Test1 {
    public static void main(String[] args) {
        int[] nums = {1,2,3,4,5,6,7};
        int k = 4;
        k %= nums.length;
        int[] newArr = Arrays.copyOf(nums,nums.length);
        newArr[k-1] = nums[nums.length-1];
        for (int i = 0; i < newArr.length-3; i++) {
            newArr[k+i] = nums[i];
        }
        for (int i = 0; i < k-1; i++) {
            newArr[i] = nums[k+i+1];
        }
        System.out.println(Arrays.toString(newArr));
    }
}
